package at.fhj.pse.pageobjects;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

public class WelcomePage
{
	private WebDriver driver;

	/*
	 * Constructor
	 */

	public WelcomePage(WebDriver driver)
	{
		this.driver = driver;
	}


	/*
	 * Text: <h2>message</h2>
	 */
	public String getMessage()
	{
		return driver.findElement(By.cssSelector("h2")).getText();
	}

	public String getLoggedInUsername()
	{
		return driver.findElement(By.xpath("/html/body/div[1]/header/div")).getText();
	}

	
	/*
	 * Action: logout
	 */
	public LoginPage logout()
	{
		driver.findElement(By.xpath("//*[@id=\"logoutForm\"]/input[2]")).click();
		return new LoginPage(driver);
	}
	
	
	/*
	 * Method: NavigateToAddTimeinterval
	 */
	public AddIntervalsPage navigateToAddTimeinterval()
	{
		driver.findElement(By.xpath("//*[@id=\"j_idt20:j_idt21\"]/ul/li[5]/a/span[2]")).click();
		return new AddIntervalsPage(driver);
	}
	
	/*
	 * Method: NavigateToShowTimeinterval
	 */
	public ShowIntervalsPage navigateToShowTimeinterval()
	{
		driver.findElement(By.xpath("//*[@id=\"j_idt20:j_idt21\"]/ul/li[6]/a/span[2]")).click();
		return new ShowIntervalsPage(driver);
	} 
	 
	/*
	 * Method: NavigateToIntervalsPerDayPage
	 */
	public IntervalsPerDayPage navigateToIntervalsPerDayPage()
	{
		driver.findElement(By.xpath("//*[@id=\"j_idt20:j_idt21\"]/ul/li[7]/a/span[2]")).click();
		return new IntervalsPerDayPage(driver);
	}
	
	/*
	 * Method: NavigateToIntervalsPerMonthPage
	 */
	public IntervalsPerMonthPage navigateToIntervalsPerMonthPage()
	{
		driver.findElement(By.xpath("//*[@id=\"j_idt20:j_idt21\"]/ul/li[8]/a/span[2]")).click();
		return new IntervalsPerMonthPage(driver);
	}
	
	/*
	 * Method: navigateToDaysMoreThan10hPage
	 */
	public DaysMoreThan10hPage navigateToDaysMoreThan10hPage()
	{
		driver.findElement(By.xpath("//*[@id=\"j_idt20:j_idt21\"]/ul/li[9]/a/span[2]")).click();
		return new DaysMoreThan10hPage(driver);
	}
	
	/*
	 * Method: navigateToTimeChartPage
	 */
	public TimeChartPage navigateToTimeChartPage()
	{
		driver.findElement(By.xpath("//*[@id=\"j_idt20:j_idt21\"]/ul/li[11]/a/span[2]")).click();
		return new TimeChartPage(driver);
	}
	
	/*
	 * Method: navigateToHoursPerActivityPage
	 */
	public HoursPerActivityPage navigateToHoursPerActivityPage()
	{
		driver.findElement(By.xpath("//*[@id=\"j_idt20:j_idt21\"]/ul/li[3]/a/span[2]")).click();
		return new HoursPerActivityPage(driver);
	} 
}


